package io.renren.modules.sale.controller;

import io.renren.common.annotation.SysLog;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.common.validator.ValidatorUtils;
import io.renren.common.validator.group.AddGroup;
import io.renren.common.validator.group.UpdateGroup;
import io.renren.modules.sale.entity.SaleCustomEntity;
import io.renren.modules.sale.entity.SaleOrderEntity;
import io.renren.modules.sale.service.SaleOrderService;
import io.renren.modules.sys.controller.AbstractController;
import io.renren.modules.sys.entity.SysUserEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/sale/order")
public class SaleOrderController extends AbstractController {
    @Autowired
    private SaleOrderService saleOrderService;
    /**
     * 所有用户列表
     */
    @RequestMapping("/list")
//    @RequiresPermissions("sys:user:list")
    public R list(@RequestParam Map<String, Object> params){
        SysUserEntity sysUserEntity = this.getUser();

        PageUtils page = saleOrderService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     * 保存用户
     */
    @SysLog("保存用户")
    @RequestMapping("/save")
//    @RequiresPermissions("sys:user:save")
    public R save(@RequestBody SaleOrderEntity custom){
        ValidatorUtils.validateEntity(custom, AddGroup.class);

        saleOrderService.save(custom);

        return R.ok();
    }

    /**
     * 修改用户
     */
    @SysLog("修改用户")
    @RequestMapping("/update")
//    @RequiresPermissions("sys:user:update")
    public R update(@RequestBody SaleCustomEntity custom){
        ValidatorUtils.validateEntity(custom, UpdateGroup.class);

//        saleCustomService.update(custom);

        return R.ok();
    }
}
